package jmars.mobile.domain;

import java.text.SimpleDateFormat;
import java.util.Date;

public class DateFeature {
	private Date min;
	private Date max;
	SimpleDateFormat sdf=new SimpleDateFormat();
	
	public DateFeature(String pattern){
		sdf.applyPattern(pattern);
	}
	
	public void update(Date item){
		if(null==this.getMin()||this.getMin().getTime()>item.getTime())this.setMin(item);
		if(null==this.getMax()||this.getMax().getTime()<item.getTime())this.setMax(item);
	}
	
	@Override
	public String toString(){
		StringBuffer sb =new StringBuffer();
		if(min!=null)sb.append("min:"+sdf.format(min)+", ");
		if(max!=null)sb.append("max:"+sdf.format(max));
		return sb.toString();
	}

	public Date getMin() {
		return min;
	}

	public void setMin(Date min) {
		this.min = min;
	}

	public Date getMax() {
		return max;
	}

	public void setMax(Date max) {
		this.max = max;
	}
	
}
